{% extends "base.html" %}
{% block title %} 搜索结果{% endblock %}
{% block header %}

{% endblock %}
{% block content %}


<div class="container">
  <div class="span12">
    <div class="alert alert-info">
      <a class="close" data-dismiss="alert">×</a>
      <h5>Tips, remove me!</h5>
      <ul>
        <li>top banner: 位于右边的功能菜单（登陆、退出等），在登陆前后，选项应该是有所不同的。</li>
        <li>只显示未被购买的商品。</li>
        <li>点击图片进入商品详细信息页面。</li>
        <li>点击图片下面的“标签”，则以该标签作为搜索条件显示商品列表。</li>
      </ul>
    </div>
  </div>
</div>

<div class="container">
  <div class="span12">
    <form class="well form-search" action="/search/">
      <select name="type">
        <option id="name" value="name">商品名称</option>
        <option id='tags' value="tags">标签</option>
        <option id='price' value="price">价格小于</option>
      </select>
      <input type="text" class="input-small search-query" placeholder="请输入.." name="kwd" value="{{kwd}}">
      <button type="submit" class="btn">搜索</button>
    </form>
  </div>
</div>

<div class="container">
  <div class="span12">
    <ul class="thumbnails">
      {% for g in goods %}
      <li class="span4">
        <div class="thumbnail">
          <a href="\item_detail\?gid={{g.id}}"><img src="{{g.img}}" alt="" width="260"></a>
          <h2>{{g.name}}</h2>

          <h4>标签：
            {% for tag in g.tags %}
            <a href="\search\?type=tags&kwd={{tag}}"><span class="label">{{tag}}</span></a>
            {% endfor %}
          </h4>
          <h4>价格：{{g.price}}元</h4>
        </div>
      </li>
      {% else %}
      <h3>空空如也~</h3>
      {% endfor %}



    </ul>
  </div>

  {% if goods %}
  <div class="span12">
    <div class="pagination pagination-centered">
      <ul>
        {% if now_page == 1 %}
        <li class="disabled"><a href="">&laquo;</a></li>
        {% else %}
        <li><a href="/search/?page={{now_page-1}}&type={{c_type}}&kwd={{kwd}}">&laquo;</a></li>
        {% endif %}

        {% for i in all_page %}
        {% if i== now_page %}
        <li class="active"><a href="/search/?page={{i}}&type={{c_type}}&kwd={{kwd}}">{{i}}</a></li>
        {% else%}
        <li><a href="/search/?page={{i}}&type={{c_type}}&kwd={{kwd}}">{{i}}</a></li>
        {% endif%}
        {% endfor %}

        {% if now_page == count_page %}
        <li class="disabled"><a href="">&raquo;</a></li>
        {% else %}
        <li><a href="/search/?page={{now_page+1}}&type={{c_type}}&kwd={{kwd}}">&raquo;</a></li>
        {% endif %}


      </ul>
    </div>
  </div>
  {% endif %}

  {% endblock %}
  {% block js %}
  <script>
    $('#{{c_type}}').attr('selected',true)
  </script>

  {% endblock %}